package tobsn.locationcalendar.map;

import com.google.android.maps.GeoPoint;

import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.util.Log;

public class CurrentLocationListener implements LocationListener {

	private TobsnMapActivity mContext;
	private GeoPoint mCurrentLocation;

	public CurrentLocationListener(TobsnMapActivity context) {
		mContext = context;
	}

	@Override
	public void onLocationChanged(Location location) {
		Double lat = location.getLatitude() * 1E6;
		Double lng = location.getLongitude() * 1E6;
		mCurrentLocation = new GeoPoint(lat.intValue(), lng.intValue());
		Log.d("LocationUpdate", "latitude: " + lat.intValue()
				+ " longitude: " + lng.intValue());

		mContext.updatePosition(mCurrentLocation);
		mContext.showDistance();
	}

	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub

	}
	
	public GeoPoint getCurrentLocation(){
		return mCurrentLocation;
	}

}
